<!--
    group: 发票管理
    name: 申请开票
    item: 变更征收方式弹层
-->
<template>
  <a-modal
    :width="config.width"
    :footer="null"
    :title="config.modalTitle"
    :destroyOnClose="true"
    :closable="false"
    v-model="config.visible"
  >
    <!--选择核定方式-->
    <div v-if="config.isOverrun == 1" class="methodVerification">
      <h4><a-icon type="exclamation-circle" theme="filled" />为满足您的开票金额需求，您的纳税模式将变更更为“核定征收-征收率”！</h4>

      <div class="ratify">
        <div class="ratify_item">
          <span class="item item_one">选择</span>
          <span class="item item_two">征收方式</span>
          <span class="item item_three">说明</span>
        </div>
        <div class="ratify_item">
          <span class="item item_one">&nbsp;</span>
          <span class="item item_two">
              核定征收-双定
              <span class="middle_tax">使用中纳税模式</span>
            </span>
          <div class="item item_three desc">
            <span>1、不具备建账建制条件（能力）的个体工商户</span>
            <span>2、月收入不超过增值税、个人所得税双免政策额度</span>
          </div>
        </div>
        <div class="ratify_item">
            <span class="item item_one">
              <a-radio default-checked />
            </span>
          <span class="item item_two">
              <span>核定征收-征收率</span>
              <span class="sell">推荐!</span>
            </span>
          <div class="item item_three desc">
            <span>1、不具备建账建制条件（能力）的个体工商户</span>
            <span>2、年开票不超过470万元 </span>
          </div>
        </div>
      </div>
      <p class="tips">本次变更将收取手续费500元</p>

      <div class="desc_btn">
        <a-button type="primary" class="btnsLarge" @click="sureVerification">{{config.source == 4 ? '提交服务申请' : '确定'}}</a-button>
        <a @click="goBack">返回上一步</a>
      </div>
    </div>

    <!--开票列表---批量结算 变更征收方式友好提示-->
    <div v-if="config.base == 'list' && config.isOverrun == 3 && config.source == 4">
      现在进行征收方式变更，将取消您已提交的结算订单，您确定要这么做吗?

      <div class="desc_btn">
        <a-button @click="confirmSubmission" type="primary">确认提交</a-button>
        <a-button @click="cancelChanges" type="default" class="mLeft">取消变更</a-button>
      </div>
    </div>

    <!--生成业务-->
    <div v-if="config.isOverrun == 2" class="business">
      <h4>
        <a-icon type="check-circle" theme="filled" />
        您的业务已生成，请及时关注业务进展！
      </h4>

      <template v-if="businessList && businessList.length > 0">
        <div class="business_item" v-for="item in businessList">
          <h6>{{{1008:'变更企业纳税模式',1016:'变更企业服务模式'}[item.businessType] || ''}}</h6>
          <p v-if="item.preInfo"><span class="business_name">变更前：</span>{{ item.preInfo }}</p>
          <p v-if="item.praInfo"><span class="business_name">变更后：</span>{{ item.praInfo }}</p>
          <p class="last_item">
            <span class="business_name">业务状态：</span>
            <!--businessType 业务类型（1003-开票服务费 1004-退票服务 1008-税务变更服务费 1016-服务模式变更 ）-->
            {{{1008:'业务',1016:'资料'}[item.businessType] || ''}}
            <!--status 0-待完善;1-待审核;2-审核驳回;3-待支付;4-办理中;5-已完成;6-已开票;7-已取消;8-支付失败-->
            {{{0:'待完善',1:'待审核',2:'审核驳回',3:'待支付',4:'办理中',5:'已完成',6:'已开票',7:'已取消',8:'支付失败'}[item.status] || ''}}
          </p>
          <p class="business_btn">
            <a @click="businessDetails(item.flowNo,item.businessType)">详情<a-icon type="right" /></a>
          </p>
        </div>
      </template>

      <div class="business_item">
        <h6>申请开具发票</h6>
        <p class="last_item"><span class="business_name">业务状态：</span>申请开具发票</p>
        <p class="business_btn"></p>
      </div>

      <div class="desc_btn">
        <a-button type="primary" class="btnsLarge" @click="sureBusiness">确认</a-button>
      </div>
    </div>

  </a-modal>
</template>

<script>
import { getInvocieBiz,getTaxInfoSub } from '@api/invoiceAdminister'
export default {
  name: 'changeCollectionMethod',
  props:['config','entId'],
  data(){
    return{
      businessList: [],   //生成业务
      // config: {
      //   width: '800px',
      //   visible: true,
      //   source: '',   //来源   3-单笔结算  4-批量结算
      //   base: '',   //出发地   apply-申请开票   list-开票列表
      //   isOverrun: 1,
      // }
    }
  },
  methods:{
    //  ---------------------------- 变更征收方式相关操作 ↓ -------------------------------
    //确定---变更征收方式
    sureVerification(){
      if(this.config.base == 'list' && this.config.source == 4){
        this.config.width = '500px';
        this.config.isOverrun = 3;
      }else{
        this.changeInterface();
      }
    },
    //返回上一步
    goBack(){
      //子组件调用父组件方法
      this.$emit('fatherBackMethod',this.config);
    },
    //  ---------------------------- 友好提示返回提交操作 ↓ -------------------------------
    //确认提交
    confirmSubmission(){
      this.changeInterface();
    },
    //取消变更
    cancelChanges(){
      this.config.width = '800px';
      this.config.isOverrun = 1;
    },
    //调用确认变更接口
    changeInterface(){
      let params = {};
      params.entId = this.entId;
      params.newTaxMode = 3;  //新征收方式 1-查账征收2-核定征收-双定3-核定征收-征收率4-核定征收-应纳税所得率
      getTaxInfoSub(params).then(res => {
        if (res.success) {
          if (res.result){
            this.getGenerateBusiness();   //生成业务数据

            this.config.width = '800px';
            this.config.isOverrun = 2;
          }
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //  ---------------------------- 生成业务相关操作 ↓ -------------------------------
    //确认
    sureBusiness(){
      this.config.visible = false;
    },
    //生成业务详情
    businessDetails(id,type){
      //type 业务类型 1008-税务变更服务费 1016-服务模式变更
      let pageNum;   //前端页面公用详情定义的页面编码
      if (type == 1008){
        pageNum = 2;
      }else if(type == 1016){
        pageNum = 5;
      }

      this.$router.push({
        path: '/enterprise/enterpriseList/ServicesInProgress',
        query: {
          externalId: id,
          pn: pageNum
        }
      })
    },
    //获取生成业务数据
    getGenerateBusiness(){
      let entId = this.entId;
      getInvocieBiz(entId).then(res => {
        if (res.success) {
          this.businessList = res.result || [];
        }else{
          this.$message.warning(res.message);
        }
      })
    },
  }
}
</script>

<style scoped lang="less">
//选择核定方式
.methodVerification{
  h4{
    display: flex;
    align-items: flex-start;
    font-weight: bolder;
    font-size: 20px;
    padding-left: 30px;
    margin-bottom: 20px;
    i{
      color: @color-orange;
      font-size: 50px;
      margin-right: 10px;
    }
  }
  .ratify{
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    border: 1px solid #dee0e2;
    color: #101010;
    .ratify_item{
      width: 100%;
      display: flex;
      align-items: center;
      .item{
        text-align: center;
        height: 100%;
        padding: 5px 0;
        display: inline-block;
      }
      .item_one{width: 50px;display: flex;align-items: center;justify-content: center;}
      .item_two{
        flex: 2;
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        align-items: center;
        span{
          width: 100%;
        }
        .sell{
          width: 60px;
          background: @color-blue;
          font-size: 14px;
          border-radius: 20px;
          line-height: 28px;
          color: #FFFFFF;
          display: block;
        }
        .middle_tax{
          margin-top: 10px;
          width: 100%;
          text-align: center;
          color: @color-blue;
        }
      }
      .item_three{flex: 3;padding-left: 10px;}
      .desc{
        width: 100%;
        text-align: left;
        box-sizing: border-box;
        padding-top: 20px;
        span{
          display: block;
        }
      }
      .item_one,.item_two{
        border-right: 1px solid #dee0e2;
      }
    }
    .ratify_item:nth-child(1){
      background: #F8F8F8;
      border-bottom: 1px solid #dee0e2;
      font-weight: bolder;
    }
    .ratify_item:nth-child(2){
      border-bottom: 1px solid #dee0e2;
      //border: 2px solid @color-green;
      background: #eef1fd;
    }
  }
  .tips{
    width: 100%;
    //text-align: center;
    margin-top: 10px;
    margin-left: 5px;
    color: @color-lightGary;
    //font-weight: bolder;
  }



}

//生成业务
.business{
  h4{
    display: flex;
    align-items: center;
    font-weight: bolder;
    font-size: 20px;
    padding-left: 30px;
    margin-bottom: 20px;
    i{
      color: @color-blue;
      font-size: 50px;
      margin-right: 10px;
    }
  }

  .business_item{
    width: 100%;
    //background: #F9F8F9;
    border-bottom: 1px solid #dee0e2;
    //border-radius: 10px;
    padding: 20px 10px;
    //margin-top: 20px;
    color: #101010;
    h6{
      color: #101010;
      font-weight: bolder;
      font-size: 14px;
      margin-bottom: 20px;
    }
    .business_name{
      display: inline-block;
      width: 100px;
      text-align: right;
      font-size: 14px;
      color: #999999;
      //font-weight: bolder;
    }
    .last_item{
      margin-bottom: 0;
    }
    .business_btn{
      margin-bottom: 5px;
      width: 100%;
      text-align: right;
    }
  }
}

.desc_btn{
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin: 40px 0 20px 0;
  text-align: center;
}
.desc_btn a{
  margin-left: 10px;
  //text-decoration: underline;
}
</style>
